/*
	Copyright (C) 2010 2011 Rémi Thebault

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GANTTMTASK_H
#define GANTTMTASK_H

#include <QGraphicsItem>

#include <procycle/macrotask.h>

#include "gantttask.h"


class GanttMTask : public GanttTask
{
public:
	GanttMTask(ProCycle* app, PC::MacroTask* task, GanttCycle* gcycle, GanttMTask* parent=0);
	virtual ~GanttMTask() {
	}


	QRectF boundingRect() const;

	virtual void paintTaskBar(QPainter* painter);

	virtual bool pointOnTaskBar(const QPointF &p);

	PC::MacroTask* mTask() {
		return static_cast<PC::MacroTask*>(m_task);
	}


	virtual void replaceChildren();

	void processExpansionChange();

	void addTask(GanttTask* gt);
	void insertTask(GanttTask* gt, int pos);
	void removeTask (GanttTask* gt);
	void removeAllTasks();


	GanttTask* resolvTask(QString tbsId);
	GanttTask* resolvAbsoluteTask(QString tbsId);


	virtual void resetTask(PC::Task* task);

	virtual void setZPos(int zPos) {
		GanttTask::setZPos(zPos);
		foreach(GanttTask* gt, m_gtasks) {
			gt->setZPos(zPos);
		}
	}

	virtual void setCycleProp(PC::Cycle::Property p, const QVariant& value);
	virtual void editModeChanged();

	virtual int barTop() {
		return 9;
	}

	virtual int barHeight() {
		return 8;
	}

	virtual int linkDockY() {
		return 13;
	}

	virtual int barBottom() {
		return 21;
	}

protected:

	QList<GanttTask*>	m_gtasks;
};

#endif // GANTTMTASK_H
